package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags="护理等级")
@RequestMapping("/nursingLevel")
public class NursingLevelController extends  BaseController{

    @Autowired
    NursingLevelService nursingLevelService;

    @ApiOperation("查询所有护理等级")
    @GetMapping("/listAll")
    public ResponseResult<List<NursingLevelVo>> getAll(){

        List<NursingLevelVo> nursingLevelVoList=nursingLevelService.getAll();
        return success(nursingLevelVoList);
    }
    @ApiOperation("新增护理等级")
    @PostMapping("/insert")
    public ResponseResult insertLevel(@RequestBody NursingLevelDto nursingLevelDto){

        nursingLevelService.addLevel(nursingLevelDto);
        return success();
    }

    @ApiOperation("根据id查询等级")
    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> betById(
            @PathVariable("id") Integer id
    ){

        NursingLevelVo nursingLevelVo= nursingLevelService.getById(id);
        return success(nursingLevelVo);
    }

    @ApiOperation("条件分页查询")
    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> queryPage(
            @ApiParam("页码")
            Integer pageNum,
            @ApiParam("每页大小")
            Integer pageSize,
            @ApiParam("护理等级名称")
            String name,
            @ApiParam("护理等级状态")
            Integer status
    ){

        PageResponse<NursingLevelVo> levelPageR= nursingLevelService.queryPage(pageNum,pageSize,name,status);
        return success(levelPageR);
    }
    @ApiOperation("编辑护理等级")
    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.updateLevel(nursingLevelDto);
        return success();
    }

    @ApiOperation("删除护理等级")
    @DeleteMapping("/delete/{id}")
    public ResponseResult DeleteNursingLevel(@PathVariable("id") Integer id){
        nursingLevelService.deleteNursingLevel(id);
        return success();
    }

    @ApiOperation("启用禁用")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult setStatus(
            @PathVariable("id") Integer id,
            @PathVariable("status") Integer status

    ){
        nursingLevelService.setStatus(id,status);
        return success();
    }

}
